<div class="bjui-pageContent">
    <form action="{:U('save_attr')}" data-callback="dialogFormCall" data-toggle="validate" data-alertmsg="false" class="dialogForm">
        <input type="hidden" name="id" value="{$va.id}"/>
        <div class="form-group">
            <label class="x100">属性名称:</label>
            <input type="text" name="name" data-rule="required" value="{$va.name}"/>
        </div>
        <!-- <div class="form-group">
            <label class="x100">所属商品分类:</label>
            <select name="category_id[]" data-toggle="selectpicker" multiple data-width="400">
                <option value="">--请选择--</option>
                <volist name="res" id="ro">
                <option value="{$ro.id}" <if condition="in_array($ro['id'],$va['category_ids'])">selected</if>>{$ro.name}</option>
                </volist>
            </select>
        </div> -->
        <div class="form-group">
            <label class="x100">检索:</label>
            <input type="radio" name="search" value="1" id="attr_search1" data-toggle="icheck" data-label="开启"  <if condition="$va.search neq '0'">checked</if>  />
            <input type="radio" name="search" value="0" id="attr_search2" data-toggle="icheck" data-label="关闭"  <if condition="$va.search eq '0'">checked</if> />
        </div>
        <div class="form-group">
            <label class="x100">录入方式:</label>
            <input type="radio" name="type" value="1" id="attr_addtype1" data-toggle="icheck" data-label="单选" <if condition="$va.type eq '1' or $va eq null">checked</if>/>
            <input type="radio" name="type" value="2" id="attr_addtype2" data-toggle="icheck" data-label="多选" <if condition="$va.type eq '2'">checked</if>  />
            <input type="radio" name="type" value="3" id="attr_addtype3" data-toggle="icheck" data-label="下拉" <if condition="$va.type eq '3'">checked</if>  />
            <input type="radio" name="type" value="4" id="attr_addtype4" data-toggle="icheck" data-label="文本"  <if condition="$va.type eq '4'">checked</if>  />
            <input type="radio" name="type" value="5" id="attr_addtype5" data-toggle="icheck" data-label="多行文本" <if condition="$va.type eq '5'">checked</if>  />
        </div>
        <div class="form-group">
            <label class="x100">可选值例表:</label>
            <input type="text" class="tagsu" data-tagname="value[]" data-toggle="tags" data-url="{:U('Index/save')}" data-width="400" size="15" placeholder="输入选项，回车提交">
        </div>
        <div class="form-group">
            <label class="x100">&nbsp;</label>
            <span class="text-warning">录入方式为"文本"或者"多行文本"时，此输入框不需填写</span>
        </div>
        <div class="form-group">
            <label class="x100">权重:</label>
            <input type="text" name="sort" data-toggle="spinner" data-min="0" data-step="1" data-rule="integer" class="w100" value="{$va.sort}" />
        </div>
    </form>
</div>
<script>

    $(function () {
        setTimeout(function () {
//            可选值列表 默认值
            var defaultTags = {$va.value|default="[]"},
                    tags = $('.bjui-tags');
            for (var i = 0 ; i < defaultTags.length; i++ ){
                tags.prepend('<span class="label label-tag" data-value="'+defaultTags[i]+'" style="margin-left: 1px; margin-top: 1px;"><i class="fa fa-tag"></i> '+defaultTags[i]+'&nbsp;&nbsp;<a href="#" class="close">×</a></span>');
                tags.append('<input type="hidden" name="value[]" value="'+defaultTags[i]+'">');
            }
            $('.label-tag', tags).find('a.close').click(function () {
               var p =  $(this).parents('.label-tag').attr('data-value');
                $(this).parents('.label-tag').remove();
                tags.find('input[type=hidden]').each(function (index, item) {
                    if( this.value == p ){
                        $(this).remove();
                    }
                })
            });
        });

    });
</script>
<include file="Common/footer" ftype="save" />